There are four pillars of OOP:
- Data Hiding: Concept: Protecting data from direct external access. In JavaScript: Use closures or private variables to limit access to specific properties.
- Inheritance: Concept: Creating new objects based on existing ones. In JavaScript: Implement inheritance through prototype chains or ES6 class inheritance.
- Polymorphism: Concept: Treating different objects as if they’re of a common type. In JavaScript: Achieve polymorphism by method overriding or function overloading.
- Encapsulation: Concept: Bundling data and methods into a single unit (class). In JavaScript: Use object literals or class definitions to group related data and functions for clean and modular code.
Thanks chatgpt! 😇